package com.ruoyi.app.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.app.domain.AppReturnReservations;
import com.ruoyi.app.service.IAppReturnReservationsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 返校预约Controller
 * 
 * @author ruoyi
 * @date 2025-11-04
 */
@RestController
@RequestMapping("/app/reservations")
public class AppReturnReservationsController extends BaseController
{
    @Autowired
    private IAppReturnReservationsService appReturnReservationsService;

    /**
     * 查询返校预约列表
     */
    @PreAuthorize("@ss.hasPermi('app:reservations:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppReturnReservations appReturnReservations)
    {
        startPage();
        List<AppReturnReservations> list = appReturnReservationsService.selectAppReturnReservationsList(appReturnReservations);
        return getDataTable(list);
    }

    /**
     * 导出返校预约列表
     */
    @PreAuthorize("@ss.hasPermi('app:reservations:export')")
    @Log(title = "返校预约", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppReturnReservations appReturnReservations)
    {
        List<AppReturnReservations> list = appReturnReservationsService.selectAppReturnReservationsList(appReturnReservations);
        ExcelUtil<AppReturnReservations> util = new ExcelUtil<AppReturnReservations>(AppReturnReservations.class);
        util.exportExcel(response, list, "返校预约数据");
    }

    /**
     * 获取返校预约详细信息
     */
    @PreAuthorize("@ss.hasPermi('app:reservations:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appReturnReservationsService.selectAppReturnReservationsById(id));
    }

    /**
     * 新增返校预约
     */
    @PreAuthorize("@ss.hasPermi('app:reservations:add')")
    @Log(title = "返校预约", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppReturnReservations appReturnReservations)
    {
        return toAjax(appReturnReservationsService.insertAppReturnReservations(appReturnReservations));
    }

    /**
     * 修改返校预约
     */
    @PreAuthorize("@ss.hasPermi('app:reservations:edit')")
    @Log(title = "返校预约", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppReturnReservations appReturnReservations)
    {
        return toAjax(appReturnReservationsService.updateAppReturnReservations(appReturnReservations));
    }

    /**
     * 删除返校预约
     */
    @PreAuthorize("@ss.hasPermi('app:reservations:remove')")
    @Log(title = "返校预约", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appReturnReservationsService.deleteAppReturnReservationsByIds(ids));
    }
}
